package com.canton.dao.entity;

import java.io.Serializable;

/**
 * @author: wujunchao
 * @date: 2021-12-04 20:59
 */
public class CommonResult implements Serializable {
    private static final long serialVersionUID = -3948389268046368059L;

    private String code;

    private String msg;

    private Object data;

    public CommonResult() {}

    public CommonResult(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static CommonResult success() {
        CommonResult Result = new CommonResult();
        Result.setCode(ResponseCode.SUCCESS);
        return Result;
    }

    public static CommonResult success(Object data) {
        CommonResult Result = new CommonResult();
        Result.setCode(ResponseCode.SUCCESS);
        Result.setData(data);
        return Result;
    }

    public static CommonResult failure(String code, String msg) {
        CommonResult Result = new CommonResult();
        Result.setCode(code);
        Result.setMsg(msg);
        return Result;
    }

    public static CommonResult failure(String code, String msg, Object data) {
        CommonResult Result = new CommonResult();
        Result.setCode(code);
        Result.setMsg(msg);
        Result.setData(data);
        return Result;
    }

    public String getCode() {
        return this.code;
    }

    public void setCode(final String code) {
        this.code = code;
    }

    public String getMsg() {
        return this.msg;
    }

    public void setMsg(final String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return this.data;
    }

    public void setData(final Object data) {
        this.data = data;
    }
}
